#!/usr/bin/env bash

if [[ ! -d "./target" ]]; then
    mkdir ./target
    echo "mkdir target success!"
fi

rm -rf ./target/*
echo "clear dir target sucess"
cp -r ./src ./target/game
yes | cp -i ./src/config/config-prod-fk.js ./target/game/config/config.js
yes | cp -i ./src/const-prod.js ./target/game/const.js
yes | cp -i ./src/config/redis-prod.json ./target/game/config/redis.json
yes | cp -i ./src/config/session-prod.json ./target/game/config/session.json
rm ./target/game/config/config-prod.js
rm ./target/game/config/config-test.js
rm ./target/game/config/config-gprod.js
rm ./target/game/config/session-prod.json
rm ./target/game/config/session-test.json
rm ./target/game/config/redis-prod.json
rm ./target/game/config/redis-test.json
rm -rf ./target/game/config
rm -rf ./target/game/node_modules
rm -rf ./target/game/log

echo ""
echo "cp src to target game success!"

cd ./target
echo "cd dir target:"
pwd
tar -cvf ./game.tar.gz ./game
rm -rf ./game
echo "package game success!"